package cn.wolfcode.luowowo.util;

import cn.wolfcode.luowowo.exception.LogicException;

public abstract class AssertUtil {

    public static final String PHONE_REGEX = "^[1][3,4,5,7,8][0-9]{9}$";

    public static void hasLength(String str, String msg) {
        if (str == null || "".equals(str.trim())) {
            throw new LogicException(msg);
        }
    }

    /**
     * 判断是否是手机号
     *
     * @param checkPhone
     */
    public static void isPhoneNumber(String checkPhone) {
        if (checkPhone == null || "".equals(checkPhone)) {
            throw new LogicException("手机号不能为空");
        }
        if (!checkPhone.matches(PHONE_REGEX)) {
            throw new LogicException("请输入正确的手机号码");
        }
    }

}
